package org.easyx.core.utils;

import java.io.Serializable;

/**
 * ajax 返回对象工具
 */
public class AjaxRetKit {
	
	/**
     * ajax失败
     * @param msg 失败的消息
     */
    public static Object renderError(String msg) {
        Result Result = new Result();
        Result.setMsg(msg);
        return Result;
    }

    /**
     * ajax成功
     */
    public static Object renderSuccess() {
        Result Result = new Result();
        Result.setSuccess(true);
        return Result;
    }

    /**
     * ajax成功
     * @param msg 消息
     */
    public static Object renderSuccess(String msg) {
        Result Result = new Result();
        Result.setSuccess(true);
        Result.setMsg(msg);
        return Result;
    }

    /**
     * ajax成功
     * @param msg 消息
     * @param obj 成功时的对象
     */
    public static Object renderSuccess(String msg, Object obj) {
        Result Result = new Result();
        Result.setSuccess(true);
        Result.setMsg(msg);
        Result.setObj(obj);
        return Result;
    }
    
    
    /**
     * 操作结果集
     */
   static class Result implements Serializable {
        private static final long serialVersionUID = 5576237395711742681L;
        
        private boolean success = false;
        private String msg = "";
        private Object obj = null;

        public boolean isSuccess() {
            return success;
        }
        public void setSuccess(boolean success) {
            this.success = success;
        }
        public String getMsg() {
            return msg;
        }
        public void setMsg(String msg) {
            this.msg = msg;
        }
        public Object getObj() {
            return obj;
        }
        public void setObj(Object obj) {
            this.obj = obj;
        }
    }
    
}
